package gui.dialog;

import java.awt.AWTEvent;

public interface ConnectionListener {
	
	public class ConnectionEvent extends AWTEvent {
		
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;
		
		private String username = null ;
		private boolean accepted ;
		private boolean cancelled ;
		private boolean closed ;

		public ConnectionEvent (Object source, String username) {
			super (source, 0) ;
			this.username = username ;
			this.accepted = true ;
			this.cancelled = this.closed = false ;
		}
		
		public ConnectionEvent (Object source, boolean cancelled, boolean closed) {
			super (source, 0) ;
			this.accepted = false ;
			this.cancelled = cancelled ;
			this.closed = closed ;
		}
		
		/**
		 * @return true if the connection has been accepted
		 */
		public boolean accepted () { return this.accepted ; }
		
		/**
		 * @return true if the connection has been cancelled
		 */
		public boolean cancelled () { return this.cancelled ; }
		
		/**
		 * @return true if the connection has been stopped by closing the Window / Stopping the program
		 */
		public boolean closed () { return this.closed ; }
		
		/**
		 * @return The username corresponding to this COnnectionEvent, null if there is no username (Close or Cancel)
		 */
		public String username () { return this.username ; }
	}
	
	/**
	 * Call when user perfoms any action on connection window.
	 * 
	 * @param username
	 */
	public void actionConnect (ConnectionEvent ce) ;
	
}
